<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/12
 * Time: 17:39
 */

namespace core;


use core\request\Request;

/**
 * Class Controller
 * @package core
 * @method assign($name,$value)
 */
class Controller
{
    protected $smarty;
    public function __construct()
    {
        $this->smarty = new \Smarty();
        $req = Request::getInstance();
        $this->smarty
            ->setTemplateDir(__APP__.$req->getModule().DIRECTORY_SEPARATOR.'view/') #设置模板存放路径
            ->setCompileDir(__ROOT_PATH__.'runtime/template/')                      #设置模板编译后的缓存路径
            ->setCacheDir(__ROOT_PATH__.'runtime/cache/')
            ->setConfigDir(__ROOT_PATH__.'configs/template/')
        ;
    }

    public function __call($name, $arguments)
    {
        if (is_callable([$this->smarty,$name])){
            return call_user_func_array([$this->smarty,$name],$arguments);
        }
    }
}